package com.blank.shop.stream;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;

/**
 * @author _blank
 */
@Slf4j
@EnableBinding(Sink.class)
@SpringBootApplication
public class ShopStreamRabbitMqConsumerApplication {

    @Value("${server.port}")
    private Integer port;

    @StreamListener(Sink.INPUT)
    public void receiveMsg(Message<String> message) {
        final String payload = message.getPayload();
        log.info("方法：receiveMsg，接收体：{}，当前服务端口号：{}", payload, this.port);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(ShopStreamRabbitMqConsumerApplication.class, args);
    }

}
